package books4africa
import java.util.Date

class BookRequest {
       //sort by date -- book
        String teacher;//required -- assign based on current user
        String requestDescription;//optional
        String title;//OR category
        String category;//OR title
        int gradeLower;// 0 <= gradeLower; <= gradeHigher
        int gradeHigher;// >= gradeLower; <= 6
        int qty;//int, >0 and <500 (for an upper bound)
        String dateMinString; //mm/dd/yy format.
        //must be lower than dateMax and >= today
        String dateMaxString; //mm/dd/yy format.
        //must be higher than dateMin and >= today
        String fulfillmentList;//SQL statement?
        String commitmentList;//SQL statement?
        Date today = new Date();//date request was made (today)
            //(auto-generate? http://langref.org/groovy/dates)
        
    static constraints = {
        requestDescription(nullable: true, maxSize: 500);
        
        gradeLower(validator: {gradeLower ->
		gradeLower >= 0 && gradeLower < 7 && gradeLower <= gradeHigher});
        
        gradeHigher(validator: {gradeHigher ->
                gradeHigher >= 0 && gradeHigher < 7 && gradeHigher >= gradeLower});
        
        qty(validator: {qty ->
            gty > 0 && qty <= 500});

    }
}
